home *** CD-ROM | disk | FTP | other *** search
- ' This program draws an arc with 4 (or 5) input points.
- ' Point 1 is the center of the arc
- ' Point 2 is the beginning point of the arc (also specifies the radius of the arc)
- ' Point 3 and 4 define a line that contains the ending point of the arc
- ' which also defines the location of the ending point
- ' Point 5 is an optional point for drawing a reverse arc
-
- SETPOINT "Set points for arc: 1) Center, 2) Starting point, 3,4) Line defines the ending point, [ 5) Optional for reverse arc", 5
- NPTS = sys(1)
- IF NPTS < 4 THEN
- END
- END IF
-
- POINTVAL CX CY CZ 1
- POINTVAL SX SY SZ 2
- POINTVAL EX1 EY1 EZ1 3
- POINTVAL EX2 EY2 EZ2 4
-
- VX = EX2 - EX1
- VY = EY2 - EY1
- VZ = EZ2 - EZ1
-
- R2 = (SX - CX) * (SX - CX) + (SY - CY) * (SY - CY) + (SZ - CZ) * (SZ - CZ)
-
- A = VX * VX + VY * VY + VZ * VZ
- B = 2 * (VX * (EX1 - CX) + VY * (EY1 - CY) + VZ * (EZ1 - CZ))
- C = (EX1 - CX) * (EX1 - CX) + (EY1 - CY) * (EY1 - CY) + (EZ1 - CZ) * (EZ1 - CZ) - R2
-
- D = B * B - 4 * A * C
-
- IF D < 0 THEN
- MESSAGE "ERROR: Cannot draw an arc with the input points."
- END
- END IF
-
- IF NPTS < 5 THEN
- A$ = "N"
- ELSE
- A$ = "R"
- END IF
-
- D = SQRT(D)
- A = 2 * A
-
- T1 = (D - B) / A
- T2 = -(B + D) / A
-
- X1 = EX1 + T1 * VX
- Y1 = EY1 + T1 * VY
- Z1 = EZ1 + T1 * VZ
-
- X2 = EX1 + T2 * VX
- Y2 = EY1 + T2 * VY
- Z2 = EZ1 + T2 * VZ
-
- DX = X2 - X1
- DY = Y2 - Y1
- DZ = Z2 - Z1
- D = DX * VX + DY * VY + DZ * VZ
-
- IF D < 0 THEN
- EX = X1
- EY = Y1
- EZ = Z1
- ELSE
- EX = X2
- EY = Y2
- EZ = Z2
- END IF
-
- IF A$ = "N" THEN
- X1 = SX
- Y1 = SY
- Z1 = SZ
- X2 = EX
- Y2 = EY
- Z2 = EZ
- ELSE
- X2 = SX
- Y2 = SY
- Z2 = SZ
- X1 = EX
- Y1 = EY
- Z1 = EZ
- END IF
-
- >ARC4
- {
- <POINTXYZ [CX, CY, CZ]
- <POINTXYZ [X1, Y1, Z1]
- <POINTXYZ [X2, Y2, Z2]
- }
-
-
-
-